Skip to content

SR-2656: extra releases of dispatch_data_t objects on Linux #175

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 22, 2016

Conversation

dgrove-oss
Copy link
Contributor

Fixes an over-release problem in the wrapping overlay that
occurred in callback blocks that take DispatchData structs.
Just going through the glue layer between the Swift and C APIs
should not result in a net change in the reference count of
the dispatch_data_t object that the CDispatch layer is giving
us to hand to the Swift callback block. However, when the
temporary DispatchData struct we created in the wrapping layer
(and its wrapped __DispatchData object) went out of scope at
the end of the callback, the dispatch_data_t was released
by __DispatchData's deinit resulting in an unintended net -1
from the glue code.

We either need to add a compensating retain before entering the
callback block or suppress the release in the deinit. This patch
suppresses the release by adding an internal init that can
create DispatchData's with borrowed dispatch_data_t objects that
are not released on deinitialization.

Fixes an over-release problem in the wrapping overlay that
occurred in callback blocks that take DispatchData structs.
Just going through the glue layer between the Swift and C APIs
should not result in a net change in the reference count of
the dispatch_data_t object that the CDispatch layer is giving
us to hand to the Swift callback block.  However, when the
temporary DispatchData struct we created in the wrapping layer
(and its wrapped __DispatchData object) went out of scope at
the end of the callback, the dispatch_data_t was released
by __DispatchData's deinit resulting in an unintended net -1
from the glue code.

We either need to add a compensating retain before entering the
callback block or suppress the release in the deinit. This patch
suppresses the release by adding an internal init that can
create DispatchData's with borrowed dispatch_data_t objects that
are not released on deinitialization.
@MadCoder MadCoder merged commit 367bd95 into swiftlang:master Sep 22, 2016
@MadCoder
Copy link
Contributor

will need a branch for swift-3 too

@dgrove-oss dgrove-oss deleted the SR-2656 branch September 23, 2016 13:31
das pushed a commit that referenced this pull request Feb 21, 2017
SR-2656:  extra releases of dispatch_data_t objects on Linux

Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants